<template>
	<!-- search  -->	
	<view class="cu-bar search bg-white">
		<view class="search-form round">
			<text class="cuIcon-search"></text>
			<input v-model.trim="keywords" :adjust-position="false" type="text" placeholder="搜索点什么？"
			 confirm-type="search" @confirm="search"></input>
		</view>
		<view class="action">
			<button class="cu-btn shadow-blur round" @tap="search">搜索</button>
		</view>
	</view>
</template>

<script>
	const {
		request
	} = require('@/utils/t-request.js');
	export default {
		name: 'h-search',
		data() {
			return {
				keywords: ''
			}
		},
		methods: {
			search() {
				if(!this.keywords)return
				request({
					url: "/users/get-act",
					method: 'POST',
					data: {
						name: this.keywords
					}
				}).then(res => {
					if(res.data[0]){
						uni.navigateTo({
						  url: '/pages/home/act-detail?id='+res.data[0]._id,
						})
					}else {
						uni.showToast({
							title: '没有搜索到结果~',
							icon: 'loading',
							duration: 500
						})
					}
				});
				this.keywords = "";
			}
		}
	}
</script>

<style>

</style>
